import type { Router } from 'vue-router'
import { useAuthStore } from '@/store/modules/auth'

export function setupGuards(router: Router) {
  router.beforeEach((to) => {
    const authStore = useAuthStore()
    if (to.meta?.requiresAuth && !authStore.token) {
      return { name: 'auth.login', query: { redirect: to.fullPath } }
    }
  })
}
